package com.zensun.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zensun.system.domain.SysOperLog;
import com.zensun.system.domain.dto.SysOperLogDto;
import com.zensun.system.domain.vo.SysOperLogVo;
import com.zensun.system.mapper.SysOperLogMapper;
import com.zensun.system.service.ISysOperLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 操作日志 服务层处理
 *
 * @author gmk
 */
@Service
public class SysOperLogServiceImpl extends ServiceImpl<SysOperLogMapper, SysOperLog> implements ISysOperLogService {
    @Autowired
    private SysOperLogMapper operLogMapper;

    /**
     * 新增操作日志
     *
     * @param operLog 操作日志对象
     */
    @Override
    public void insertOperlog(SysOperLog operLog) {
        operLog.setOperTime(new Date());
        operLogMapper.insert(operLog);
    }

    @Override
    public List<SysOperLogVo> list(SysOperLogDto operLogDto) {
        return operLogMapper.selectOperLogList(operLogDto);
    }

    /**
     * 批量删除系统操作日志
     *
     * @param operIds 需要删除的操作日志ID
     * @return 结果
     */
    @Override
    public int deleteOperLogByIds(Long[] operIds) {
        List<Long> list = new ArrayList<Long>();
        for (Long row : operIds) {
            list.add(row);
        }
        return operLogMapper.deleteBatchIds(list);
    }

    /**
     * 清空操作日志
     */
    @Override
    public void cleanOperLog() {
        operLogMapper.cleanOperLog();
    }
}
